package top.hcode.hoj.dao.group;

import top.hcode.hoj.dao.BaseDao;
import top.hcode.hoj.mapper.GroupMapper;
import top.hcode.hoj.pojo.entity.group.Group;
import top.hcode.hoj.pojo.vo.GroupVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @Author: LengYun
 * @Date: 2022/3/11 13:36
 * @Description:
 */
@Service
public class GroupEntityService extends BaseDao<GroupMapper, Group> {

    @Autowired
    private GroupMapper groupMapper;

    
    public IPage<GroupVO> getGroupList(int limit, int currentPage, String keyword, Integer auth, String uid, Boolean onlyMine, Boolean isRoot) {
        IPage<GroupVO> iPage = new Page<>(currentPage, limit);
        List<GroupVO> groupList = groupMapper.getGroupList(iPage, keyword, auth, uid, onlyMine, isRoot);
        return iPage.setRecords(groupList);
    }


    /**
     * 获取团队成员数量 
     * 
     * @param id 团队id
     * @return 团队成员数量
     */
    public int countMembers(Long id) {
        return groupMapper.countMembers(id);
    }

    /**
     * 获取团队下小组数量
     * 
     * @param id 团队id
     * @return 团队下团队数量
     */
    public int countTeams(Long id) {
        return groupMapper.countTeams(id);
    }
}
